
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
util.PrecacheSound( "Harvest/shockwave.wav" )

function ENT:Initialize()

	self.Entity:SetName("Nuclear Warhead")
	self.Entity:SetModel( "models/items/combine_rifle_ammo01.mdl" )

	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
		phys:EnableGravity(false)
		phys:EnableDrag(false)
		phys:EnableCollisions(false)
	end

	self.PhysObj = self.Entity:GetPhysicsObject()
	self.STime = CurTime()
	self.BTime = self.STime + 3

	self.Entity:SetNetworkedFloat( "FireTime", CurTime() )
	
end

function ENT:PhysicsUpdate()

end


function ENT:SpawnFunction( ply, tr )

	if ( !tr.Hit ) then return end

	local SpawnPos = tr.HitPos + tr.HitNormal * 36

	local ent = ents.Create( "tetanuke_head" )
	ent:SetPos( SpawnPos )
	ent:Spawn()
	ent:Activate()
	return ent
end

function ENT:Think()
	self.Entity:SetColor(0,0,0,1)
	
	if (CurTime() >= self.BTime && self.Blasted != true) then
		self.Blasted = true
		local nuke = ents.Create("sent_nuke")
		nuke:SetPos( self.Entity:GetPos() )
		nuke:SetVar("owner",self.Owner)
		nuke:Spawn()
		nuke:Activate()
	end
end

function ENT:PhysicsCollide( data, physobj )
	
end

function ENT:OnTakeDamage( dmginfo )
	
end

function ENT:Use( activator, caller )

end